<?php

namespace ctrl;

class base
{
	public static function init()
	{
		if (LoginUserInfo("userstatus") != 1 && !strpos(ROUTE['ctrl'], 'login'))
			Redirect('/admin?c=login');

		if (LoginUserInfo("gid") != 1 && !in_array(strtolower(ROUTE['ctrl'] . "_" . ROUTE['act']), array_map('strtolower', JsonDecode(LoginUserInfo("systemrole")))))
			static::tpl('你无权操作此功能！');
	}

	public static function tpl($errMsg)
	{
		$tpl = P_ROOT . 'libs/tpl/error.tpl';
		$errMsg;
		ob_end_clean();
		require $tpl;
		die;
	}
}
